package com.example.liberty.hteach;

import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

import com.example.liberty.hteach.Fragment.StudentFragment;
import com.example.liberty.hteach.Fragment.TeacherFragment;
import com.example.liberty.hteach.Fragment.VideoFragment;

import java.util.ArrayList;

import butterknife.BindArray;
import butterknife.BindView;
import butterknife.ButterKnife;

public class MainActivity extends AppCompatActivity {

//    private TabLayout tabLayout;
//    private ViewPager viewPager;

    @BindView(R.id.viewPager)
    ViewPager viewPager;
    @BindView(R.id.tabs)
    TabLayout tabLayout;
    @BindArray(R.array.titles)
    String []titles;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
//        viewPager= (ViewPager) findViewById(R.id.viewPager);
//        tabLayout= (TabLayout) findViewById(R.id.tabs);
        ButterKnife.bind(this);
        final ArrayList<Fragment> fragments=new ArrayList<>();
        fragments.add(new TeacherFragment());
        fragments.add(new StudentFragment());
        fragments.add(new VideoFragment());
        viewPager.setAdapter(new FragmentPagerAdapter(getSupportFragmentManager()) {
            @Override
            public Fragment getItem(int position) {
                return fragments.get(position);
            }

            @Override
            public int getCount() {
                return fragments.size();
            }

            @Override
            public CharSequence getPageTitle(int position) {
                return titles[position];
            }
        });
        tabLayout.setupWithViewPager(viewPager);
    }
}
